using UnityEngine;

public class JunxianUI : MonoBehaviour
{
	public UIEventListener closebtn;

	public Animator animator;

	public UISlider expslider;

	public UISprite currankflag;

	public UILabel name_label;

	public UILabel exp_label;

	public UISprite[] selectflag;

	public UISlider infoslider;

	private GameObject objui;

	private bool isshow;

	private void Start()
	{
		closebtn.onClick = OnClickcloseBtn;
	}

	public void enable()
	{
		if (objui == null)
		{
			objui = base.gameObject;
		}
		UnityVersionUtil.SetActiveRecursive(objui, state: true);
		initinfo();
		isshow = true;
		//scaleanima.Stop();
		animator.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
		Invoke("animplay", Time.deltaTime * 2f);
	}

	public void animplay()
	{
		animator.SetTrigger("popWin1");
	}

	public void initinfo()
	{
		expdata exp = MenuPlayerprefs.instance.GetExp();
		name_label.text = exp.name;
		if (exp.level >= 19)
		{
			expslider.value = 1f;
			exp_label.text = string.Empty;
			currankflag.spriteName = "19." + MenuPlayerprefs.instance.ranknameImage[exp.level - 1];
			selectflag[18].enabled = true;
			currankflag.SetDimensions(60, 52);
		}
		else
		{
			expslider.value = (float)exp.curexp / (float)exp.maxexp;
			exp_label.text = string.Empty + exp.curexp + "/" + exp.maxexp;
			currankflag.spriteName = string.Empty + exp.level + "." + MenuPlayerprefs.instance.ranknameImage[exp.level - 1];
			if (exp.level >= 15)
			{
				currankflag.SetDimensions(60, 52);
			}
			else
			{
				currankflag.SetDimensions(54, 59);
			}
			selectflag[exp.level - 1].enabled = true;
		}
		infoslider.value = (float)(exp.level - 2) / 16f;
	}

	public void OnClickcloseBtn(GameObject btn)
	{
		if (isshow)
		{
			isshow = false;
			MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
			/* scaleanima["PopWinAnimation"].time = scaleanima.clip.length;
			scaleanima["PopWinAnimation"].speed = -1f;
			scaleanima.Play(); */
			animator.SetTrigger("popWin2");
			Invoke("disable", animator.GetCurrentAnimatorStateInfo(0).length);
		}
	}

	public void disable()
	{
		animator.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
		MenuBackController.instance.BackMenuUIstate();
		UnityVersionUtil.SetActiveRecursive(objui, state: false);
	}
}
